<?php
namespace app\index\controller;

use app\BaseController;
use think\facade\Db;
use think\facade\Request;
use app\common\model\News;
namespace app\common\library\wechat;
class Wxopen extends Base
{
 public function index()
    {
 include_once "WXBizMsgCrypt.php";
$encodingAesKey = "6UIXxQOcCh6HQ5pdsXyBLKcpv0uf2SJGmjsX0bp0pRi";
    $token = "rhwTvEn3BsPMv6ZSAGsJ3vS8JGahVH";
    $appId = "wxc34321ba9f76f0ba";
    # 浏览器发送的消息
    $timeStamp = $param['timestamp'];
    $nonce = $param['nonce'];
    $msg_sign = $param['msg_signature'];
    # 待解密的消息
    $from_xml = $accredit;
    $from_xml = str_replace('AppId', 'ToUserName', $from_xml);

    $pc = new WXBizMsgCrypt($token, $encodingAesKey, $appId);
    // 第三方收到公众号平台发送的消息
    $arr = [];
    $msg = '';
    $errCode = $pc->decryptMsg($msg_sign, $timeStamp, $nonce, $from_xml, $msg);
    /*if ($errCode == 0) {
        print("解密后: " . $msg . "\n");
    } else {
        print("出错 ：".$errCode . "\n");
    }*/
    return $msg;



}

}